# Contributor: André Klitzing <aklitzing@@gmail.com>
# Maintainer: André Klitzing <aklitzing@gmail.com>
pkgname=croc
pkgver=9.6.6
pkgrel=0
pkgdesc="Easily and securely send things from one computer to another"
url="https://github.com/schollz/croc"
license="MIT"
arch="all"
makedepends="go"
subpackages="$pkgname-bash-completion $pkgname-zsh-completion"
source="https://github.com/schollz/croc/archive/refs/tags/v$pkgver/croc-$pkgver.tar.gz"
options="net" # fetch dependencies

# secfixes:
#   9.1.0-r0:
#     - CVE-2021-31603

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -v -ldflags "-X github.com/schollz/croc/v${pkgver%%.*}/src/cli.Version=v$pkgver"
}

check() {
	go test ./...
}

package() {
	install -Dm755 $pkgname -t "$pkgdir"/usr/bin/

	install -Dm644 src/install/bash_autocomplete \
		"$pkgdir"/usr/share/bash-completion/completions/croc
	install -Dm644 src/install/zsh_autocomplete \
		"$pkgdir"/usr/share/zsh/site-functions/_croc
}

sha512sums="
0e3dec57d0d1337c9f45c81fa71f6d9673cc76f5c53ae9b0068f9e388788c433debebb536a43ec578b58e80b9da482949ff16cc63a883b8085fbec54a932bde2  croc-9.6.6.tar.gz
"
